<?php


namespace app\common\model;


use think\Model;

class ExpertMoneyLog extends Model
{
    // 表名
    protected $name = 'expert_money_log';
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'int';
    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = null;
    // 追加属性
    protected $append = [
        'type_text',
    ];


    public function getTypeList()
    {
        return ['1' => __('接单收益'), '2' => __('提现')];
    }


    public function getTypeTextAttr($value, $data)
    {
        $value = $value ?: ($data['type'] ?? '');
        $list = $this->getTypeList();
        return $list[$value] ?? '';
    }

    public function getCreatetimeAttr($value)
    {
        return $value ? date('Y-m-d H:i:s', $value) : '';
    }

    public function serviceDetail()
    {
        return $this->hasOne('Serviceorderdetail', 'order_id', 'from_order_id');
    }

    public function fromuserDetail()
    {
        return $this->hasOne('User', 'id', 'from_user_id');
    }
}